/**
 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

CKEDITOR.editorConfig = function(config) {
  config.extraPlugins += (config.extraPlugins ? ',lineheight' : 'lineheight');
  config.toolbar = [
    [ 'Maximize', 'Source', 'Preview', 'Save' ]
    , [ 'Font', 'FontSize' ]
    , [ 'RemoveFormat', 'SpellChecker', 'Scayt' ]
    , [ 'NumberedList', 'BulletedList' ]
    , [ 'Outdent', 'Indent' ]
    , [ 'BidiLtr', 'BidiRtl' ]
    , [ 'Image', 'Smiley' ]
    , [ 'Link', 'Unlink' ]
    , [ 'HorizontalRule' ]
    , [ 'Table' ]
    , [ 'SpecialChar' ]
    , [ 'Find', 'Replace' ]
    , '/'
    , [ 'Undo', 'Redo' ]
    , [ 'Cut', 'Copy', 'Paste', 'PasteText' ]
    , [ 'Bold', 'Italic', 'Underline', 'Strike' ]
    , [ 'TextColor', 'BGColor' ]
    // ,['Checkbox', 'Radio', 'TextField', 'Textarea', 'Select','Button']
    , [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ]
    , ['lineheight']
    , [ 'Styles', 'Format' ]
    , [ 'Subscript', 'Superscript' ]
    , [ 'Blockquote' ]
    , [ 'ShowBlocks' ]
  ];

  // 非法字符验证
  config.protectedSource.push(/<\s*frameset[\s\S]*?>/gi) ; // <frameset> tags.
  config.protectedSource.push(/<\s*frame[\s\S]*?>/gi) ; // <frame> tags.
  config.protectedSource.push(/<\s*script[\s\S]*?\/script\s*>/gi) ; // <SCRIPT> tags.
  config.protectedSource.push(/<%[\s\S]*?%>/g) ; // ASP style server side code
  config.protectedSource.push(/<\?[\s\S]*?\?>/g) ; // PHP style server side code
  config.protectedSource.push(/(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi) ;

  //设置编辑器里字体下拉列表里的字体
  config.font_names = '宋体;黑体;楷体_GB2312;Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;

  // 移除 上传图片对话框中的链接，高级；链接中的高级，上传；功能
  config.removeDialogTabs = 'image:Link;image:dvanced;link:advanced;link:upload;';
  //开启工具栏“图像”中文件上传功能，后面的url为待会要上传action要指向的的action或servlet
  config.filebrowserImageUploadUrl = "/backstage/tool/upload/image/?type=file";
  //开启插入\编辑超链接中文件上传功能，后面的url为待会要上传action要指向的的action或servlet
  // config.filebrowserUploadUrl = '/upload/image';
  //开启flash中文件上传，这里因为不常用，我暂时就不配置了
  //config.filebrowserFlashUploadUrl = "";
  //工具栏“图像”中预览区域显示内容
  config.image_previewText = '请先将图片上传到服务器，或者直接粘贴图片的链接';

  // 按照格式添加任意多个表情名称（前提：图片存在…../ckeditor/plugins/smiley/images中）
  // config.smiley_images = ['logo.png', 'e101.gif', 'e102.gif']
  // 每行显示的表情个数
  config.smiley_columns = 10;

  //设置快捷键
  config.keystrokes = [
    [ CKEDITOR.ALT + 121 /*F10*/ , 'toolbarFocus' ], //获取焦点
    [ CKEDITOR.ALT + 122 /*F11*/ , 'elementsPathFocus' ], //元素焦点
    [ CKEDITOR.SHIFT + 121 /*F10*/ , 'contextMenu' ], //文本菜单
    [ CKEDITOR.CTRL + 90 /*Z*/ , 'undo' ], //撤销
    [ CKEDITOR.CTRL + 89 /*Y*/ , 'redo' ], //重做
    [ CKEDITOR.CTRL + CKEDITOR.SHIFT + 90 /*Z*/ , 'redo' ], //
    [ CKEDITOR.CTRL + 76 /*L*/ , 'link' ], //链接
    [ CKEDITOR.CTRL + 66 /*B*/ , 'bold' ], //粗体
    [ CKEDITOR.CTRL + 73 /*I*/ , 'italic' ], //斜体
    [ CKEDITOR.CTRL + 85 /*U*/ , 'underline' ], //下划线
    [ CKEDITOR.ALT + 109 /*-*/ , 'toolbarCollapse' ]
  ];
  //在清除图片属性框中的链接属性时 是否同时清除两边的<a>标签 plugins/image/plugin.js
  config.image_removeLinkByEmptyURL = true;
};